<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /*  
        数组和字符串
        1.创建数组  var fruits = ['Apple', 'Banana'];
        2.添加元素到数组的末尾   数组名.push(元素);
        3.删除数组末尾的元素  数组名.pop();
        4.找出某个元素在数组中索引  数组名.indexOF)(元素);
        5.从一个索引位置删除多个元素
        6.用来判断某个变量是否是一个数组对象  Array.isArray(变量)
        7.将数组中元素的位置颠倒，并返回该数组。该方法会改变原数组
          数组名.reverse()
        8.排序 数组名.sort()

        */
        var arr = [1, 22, 12];

        var arr1 = new Array();
        console.log(arr.length);

        // 创建数组
        var fruits = ['Apple', 'Banana'];
        console.log(fruits.length);
        // 2 

        // 添加元素到数组的末尾
        let newLength = fruits.push('Orange');
         // ["Apple", "Banana", "Orange"];
         console.log(fruits);
         console.log(newLength);

        //  删除数组末尾的元素
        let last = fruits.pop()  // remove Orange (from the end)
        // ["Apple","Banana"]
        console.log(fruits);
        console.log(last);

        console.log('-------------------------');
        // 找出某个元素在数组中索引
        var pos = fruits.indexOf('Banana');
        console.log(pos); // 1

        console.log(Array.isArray(fruits));  // true
        console.log(Array.isArray("123"));  // false
        // 翻转数组
        // ["Apple", "Banana", "Orange"];
        fruits.push('Orange');
        console.log(fruits);
        var nweFruits = fruits.reverse();
        console.log(nweFruits);

        console.log(fruits instanceof Array);
        console.log("虞姬" instanceof Array);
        var obj = {};
        console.log(obj instanceof Object);
        console.log("诸葛亮" instanceof Object);
        console.log("诸葛亮" instanceof String);
        console.log("诸葛亮" instanceof Boolean);
        console.log(true instanceof Boolean);

    </script>
</body>
</html>